<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta charset="utf-8">
  <title>新批次入库</title>
  <base href="<%=basePath%>">
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" type="text/css" href="layuiadmin/style/easyui/easyui.css">
</head>
<body>
  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
	      <label class="layui-form-label" style="width: 20%">材料库存批次号</label>
	      <div class="layui-input-inline">
	      	 <input class="layui-input layui-disabled" readonly = "readonly" type="text" class="layui-input" name="batchno" id="batchno" value="${materialdepot.materialdepot.batchno}" autocomplete="off" >
	      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 20%">材料编号</label>
      <div class="layui-input-inline">
      	 <input class="layui-input layui-disabled" readonly = "readonly" type="text" class="layui-input" name="materialcode" id="materialcode" value="${materialdepot.materialdepot.materialcode}" autocomplete="off" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 20%">材料名称</label>
      <div class="layui-input-inline">
      	 <input class="layui-input layui-disabled" readonly = "readonly" type="text" class="layui-input" name="materialname" id="materialname" value="${materialdepot.materialdepot.materialname}" autocomplete="off" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 20%">货柜存放位置</label>
      <div class="layui-input-inline">
      	 <input class="layui-input layui-disabled" readonly = "readonly" type="text" class="layui-input" name="depotrackcode" id="depotrackcode" value="${materialdepot.materialdepot.depotrackcode}" autocomplete="off" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 20%">库存量</label>
      <div class="layui-input-inline">
      	 <input class="layui-input layui-disabled" readonly = "readonly" type="text" class="layui-input" name="depotamount" id="depotamount" value="${materialdepot.materialdepot.depotamount}" autocomplete="off" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 20%">出库量</label>
      <div class="layui-input-inline">
        <input type="text" class="layui-input" name="inoutamount" id="inoutamount" lay-verify="required|number|validateInoutamount" placeholder="请输入出库数量" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 20%">出库负责人</label>
      <div class="layui-input-inline">
      	<select name="inoutercode" id="inoutercode" lay-verify="required">
        	<option value="">请选择负责人</option>
           	<c:forEach  var="demo" items="${operatorlist}" varStatus="status">
           	    <option value="${demo.loginname}">${demo.loginname}</option>
           </c:forEach>
        </select>
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="layuiadmin-materialdepot-form-submit" id="layuiadmin-materialdepot-form-submit" value="确认添加">
      <input type="button" lay-submit lay-filter="layuiadmin-materialdepot-form-edit" id="layuiadmin-materialdepot-form-edit" value="确认编辑">
    </div>
  </div>
  <script src="layuiadmin/layui/layui.js"></script>  
  <script src="layuiadmin/js/common/jquery.js"></script>
  <script src="layuiadmin/js/common/jquery.easyui.min.js"></script>
  <script src="layuiadmin/js/form.js"></script>
  <script>
  layui.config({
	    base: 'layuiadmin/' //静态资源所在路径
	  }).extend({
	    index: 'lib/index' //主入口模块
	  }).use(['index', 'form', 'laydate'], function(){
		  var $ = layui.$
		    ,admin = layui.admin
		    ,element = layui.element
		    ,layer = layui.layer
		    ,laydate = layui.laydate
		    ,form = layui.form;
	    
		laydate.render({
			elem: '#birthday', //弹出页的指定元素生日时期需要为时间格式
		});
		  
		//自定义验证规则
        form.verify({
        	validateInoutamount: function (value) {
        		//字符串转整数类型
        	    var depotamount = parseInt($("#depotamount").val());
        	    var inoutamount = parseInt($("#inoutamount").val());
        	    if (inoutamount > depotamount) {
        	    	return '出库数量不能超过库存量';
        	    }
            }
        });
		
	    //监听提交
	    form.on('submit(layuiadmin-materialdepot-form-submit)', function(obj){
	      	var field = obj.field; //获取提交的字段
	      	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  

	      	layer.confirm('确定操作?', function(index){
	      		admin.req({
	    		    url: 'materialdepot/saveOutdepot' //实际使用请改成服务端真实接口
	    	        ,data: field
	    	        ,type: 'POST'
	    	        ,done: function(res){
	    	        	layer.msg(res.msg);
	    	        }
	         	});
	        });
	        //parent.layui.table.reload('LAY-material-content-list'); //重载表格
	        //parent.layer.close(index); //再执行关闭 
	    });
	})

  </script>
</body>
</html>